package com.tutou.ikuser.controller;

import com.tutou.ikuser.pojo.dto.Result;
import com.tutou.ikuser.pojo.dto.UserDTO;
import com.tutou.ikuser.pojo.po.User;
import com.tutou.ikuser.service.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import static com.tutou.ikuser.util.RedisConstants.LOGIN_TOKEN_KEY;

@RestController
@RequestMapping("/userInfo")
public class UserInfoController {
    @Autowired
    private UserInfo userInfo;

    @GetMapping("/getUserInfo")
    public Result getUserInfo(@RequestHeader("Authorization") String token) {
        return userInfo.getInfoById(LOGIN_TOKEN_KEY + token);
    }

    @PostMapping("/updateUserInfo")
    public Result updateUserInfo(@RequestHeader("Authorization") String token, @RequestBody User user) {
        return userInfo.updateUserInfo(LOGIN_TOKEN_KEY +token, user);
    }
}
